package com.diy.sigmund.diycommon.test.spring.config.apollo;

import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author ylm-sigmund
 * @since 2021/10/29 19:33
 */
@ConditionalOnProperty("timeout")
@ConfigurationProperties(prefix = "test.redis")
public class SampleRedisConfig {

    private static final Logger log = LoggerFactory.getLogger(SampleRedisConfig.class);

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 在spring项目中，在一个bean的初始化过程中，方法执行先后顺序为<br>
     * Constructor > @Autowired > @PostConstruct<br>
     *
     * @see <a href="https://cloud.tencent.com/developer/article/1588212">@PostConstruct</a>
     */
    @PostConstruct
    private void initialize() {
        log.info("SampleRedisConfig initialized - name: {}", name);
    }
}
